﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace GameWP
{
    public class Layer : VisibleGame
    {
#region Properties
        protected Vector2 _parallax;
        public Vector2 Parallax
        {
            get { return _parallax; }
            set { _parallax = value; }
        }

        protected List<Sprite2D> _listSprite;
        public List<Sprite2D> ListSprite
        {
            get { return _listSprite; }
            set { _listSprite = value; }
        }

        protected Camera _camera;
        public Camera Camera
        {
            get { return _camera; }
            set { _camera = value; }
        }
#endregion

#region Initilation
        public Layer(List<Sprite2D> listSprite, Vector2 parallax, Camera camera)
        {
            _listSprite = listSprite;
            _parallax = parallax;
            _camera = camera;
        }
#endregion

#region Draw
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, _camera.GetViewMatrix(Parallax));
            for (int i = 0; i < _listSprite.Count; i++)
                _listSprite[i].Draw(spriteBatch, gameTime);
            spriteBatch.End();
        }
#endregion
    }
}
